package Z.dailyExercise.April;

public class _403青蛙过河 {
    public static void main(String[] args) {
        _403青蛙过河 test = new _403青蛙过河();
        test.canCross(new int[]{0,1,3,5,6,8,12,17});
    }

    /**
     * 自己的想法错误：可以跳过石头
     * @param stones
     * @return
     */

    public boolean canCross(int[] stones) {
        if (stones[0] != 0 || stones[1] != 1){
            return false;
        }

        int k = 1;
        int step ;
        for (int i = 2;i<stones.length;i++){
            step = stones[i]-stones[i-1];
            if ( step > k+1 || step<k-1){
                return false;
            }else {
                k = step;
            }
        }

        return true;


    }

}
